<html>
<head>
    <title>正在连接...</title>
</head>
<body>
<div id="msg"></div>
</body>
</html>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script type="text/javascript">
function getUrlParams(url) {
  let urlinfo = url.split('?');
  if(urlinfo.length == 1) return {};
  const paramsArray = url.split('?')[1].split('&');
  const params = paramsArray.reduce((acc, param) => {
    const [key, value] = param.split('=');
    acc[key] = value;
    return acc;
  }, {});
  return params;
}
let params = getUrlParams(location.href)
let url = "https://chinabp-itg.ext.hp.com.cn/uam/oauth2/authorization?appCode=MPS-FEC&redirectUrl=https://chinabp-itg.ext.hp.com.cn/fec-api/api/cbpOauthHM.html";
if(params.code == null || params.code.length < 20){
	location.href=url;
}else{
	$.ajax({
        type: "POST",
		data:JSON.stringify({"code":params.code}),
        url: "https://chinabp-itg.ext.hp.com.cn/fec-api/api/login",
        contentType:'application/json',
        success:function(data){
            //debugger;
            if(data.code != 0){
              $("#msg").html(data.msg);
              return;
            }
			sessionStorage.setItem('username',data.email);
			sessionStorage.setItem('type',0);
			sessionStorage.setItem('saveCheck',data.token);
			localStorage.setItem('username',data.email);
			localStorage.setItem('type',0);
			localStorage.setItem('saveCheck',data.token);
			location.href="https://chinabp-itg.ext.hp.com.cn/fec-api/frui/hpfecharmony/index.html";
			// location.href="http://192.168.2.11:8848/hpfecharmony/index.html";
			
			
			
        }
    });

}

    
</script>